package com.bbz.spring;

import com.bbz.spring.bean.Color;
import com.bbz.spring.bean.People;
import com.bbz.spring.config.MainConfig;
import com.bbz.spring.config.MainConfig2;
import javafx.application.Application;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.util.Map;

public class MainTest1_2 {
    public static void main(String args[]) {
        ApplicationContext applicationContext = new AnnotationConfigApplicationContext(MainConfig.class);
  /*      People people = applicationContext.getBean(People.class);
        System.out.println(people);*/
        String[] beanNames = applicationContext.getBeanDefinitionNames();
        for (String name : beanNames) {
            System.out.println(name);
        }

        Map map = applicationContext.getBeansOfType(People.class);
        System.out.println(map);
        System.out.println("*********************test()******************");
        test();
    }

    public static void test() {
        ApplicationContext applicationContext = new AnnotationConfigApplicationContext(MainConfig2.class);
        String[] beanNames = applicationContext.getBeanDefinitionNames();
        for (String beanName : beanNames) {
             System.out.println(beanName);
        }
        Color color=applicationContext.getBean(Color.class);
        System.out.println(color);
    }
}
